
#ifndef CANNYEDGESLEVELSET
#define CANNYEDGESLEVELSET
#include "itkImageLinearConstIteratorWithIndex.h"
#include "itkImportImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "USSegGUI.h"
#include "fltkImage2DViewer.h"
#include "fltkRGBImage2DViewer.h"
#include "itkImageFileWriter.h"
/**
 * \brief USSeg class that instantiate
 * the elements required for a LevelSet approach for segmentation
 *
 */
class USSeg : public USSegGUI
{
public:

  /** Dimension of the images to be registered */ 
  enum { ImageDimension3D = USSegBase::ImageDimension3D };

  /** Pixel type used for reading the input image */
  typedef   USSegBase::InputPixelType       InputPixelType;
  typedef   USSegBase::ThresholdPixelType       ThresholdPixelType;
  /** Pixel type to be used internally */
  typedef   USSegBase::InternalPixelType    InternalPixelType;

  /** Input image type */
  typedef   USSegBase::InputImageType2Ds       InputImageType2Ds;
  typedef   USSegBase::ThresholdedImageType		ThresholdedImageType;	

  /** Internal image type */
  typedef   USSegBase::InternalImageType3Df    InternalImageType3Df;
  typedef   USSegBase::InternalImageType2Df    InternalImageType2Df;

  /** Image Viewer Types */
  typedef USSegBase::SeedPixelType        OverlayPixelType;

  /** FLTK viewer module */
  typedef fltk::Image2DViewer< InternalPixelType >     InternalImageViewerType;

  typedef fltk::RGBImage2DViewer< InternalPixelType >   RGBImageViewerType;
  typedef RGBImageViewerType::Pointer				RGBImageViewerTypePointer;
  typedef InternalImageViewerType::Pointer				InternalImageViewerTypePointer;

  typedef   USSegBase::CastImage2DfTo3DfFilterType CastImage2DfTo3DfFilterType;
  typedef   USSegBase::CastImage2DcTo3DfFilterType CastImage2DcTo3DfFilterType;
  typedef   USSegBase::CastImage2DcTo3DcFilterType CastImage2DcTo3DcFilterType;
  typedef   USSegBase::CastImage2DsTo2DfFilterType CastImage2DsTo2DfFilterType;

  typedef itk::ImageFileWriter< ThresholdedImageType >  WriterType;
    typedef itk::RescaleIntensityImageFilter< 
                                  InternalImageType2Df, 
                                  ThresholdedImageType >    RescaleFilterType;
	 typedef itk::ImportImageFilter< ThresholdPixelType, 2 >   ImportFilterType;

public:
  USSeg();
  virtual ~USSeg();

  virtual void LoadInputImage();

  virtual void ShowConsole();

  virtual void ShowStatus(const char * text);

  virtual void ShowInputImage();

  virtual void ShowOutputLevelSet();

  virtual void ShowOutputCannyEdges();

  virtual void ShowGradientMagnitudeImage();

  virtual void ShowEdgePotentialImage();

  virtual void ShowThresholdedImage();

  virtual void ShowFastMarchingResultImage();
    
  virtual void Quit();

  virtual void SelectSeedPoint( int x, int y );
  
  static  void ClickSelectCallback(void * args, int& x, int& y);

  virtual void ClearSeeds();

  virtual void ExportContour();
  virtual void SaveResultImage();
  virtual void CalculateSegmentationProportion();

private:
	int m_Proportion;

  RGBImageViewerTypePointer        m_ThresholdedImageViewer;

  RGBImageViewerTypePointer        m_FastMarchingImageViewer;
  
  InternalImageViewerTypePointer         m_OutputLevelSetViewer;

  RGBImageViewerTypePointer         m_OutputCannyEdgesViewer;

  InternalImageViewerTypePointer         m_InputImageViewer;
  RGBImageViewerTypePointer         m_InputImageViewerRGB;
  InternalImageViewerTypePointer         m_GradientMagnitudeImageViewer;

  InternalImageViewerTypePointer         m_EdgePotentialImageViewer;

  InternalImageViewerTypePointer         m_ZeroSetImageViewer;

  CastImage2DfTo3DfFilterType::Pointer		  m_CastImageFilter2DfTo3Df;
  CastImage2DcTo3DfFilterType::Pointer		  m_CastImageFilter2DcTo3Df;
  CastImage2DcTo3DcFilterType::Pointer	      m_CastImageFilter2DcTo3Dc;
  CastImage2DcTo3DcFilterType::Pointer		  m_CastImageFilter2DcTo3DcSeed;

    WriterType::Pointer m_RGBWriter;
	RescaleFilterType::Pointer RescaleFilter;
	ImportFilterType::Pointer importFilter;  
};



#endif
